package com.yznu.dlm.mvp.Presenter;

import com.yznu.dlm.mvp.Model.NewsModel;
import com.yznu.dlm.mvp.Model.Tngou;
import com.yznu.dlm.mvp.view.MainView;

public class MainPresenter implements Presenter<MainView>, IMainPresenter {
    private MainView mMainView;
    private NewsModel newsModel;

    public MainPresenter(MainView view) {
        attachView(view);
        newsModel = new NewsModel(this);
    }

    @Override
    public void attachView(MainView view) {
        this.mMainView = view;
    }

    @Override
    public void detachView() {
        this.mMainView = null;
    }

    public void loadData() {
        mMainView.showProgress();
        newsModel.loadData();
    }

    @Override
    public void loadDataSuccess(Tngou tngou) {
        mMainView.showData(tngou);
        mMainView.hideProgress();
    }

    @Override
    public void loadDataFailure() {
        mMainView.hideProgress();
    }
}